Skip to content

feat: migrate warnings/errors to structured diagnostics via logs-sdk#285

Merged
antfu merged 6 commits intomainfrom
antfu/migrate-logs-sdk
Apr 17, 2026
Merged

feat: migrate warnings/errors to structured diagnostics via logs-sdk#285
antfu merged 6 commits intomainfrom
antfu/migrate-logs-sdk

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented Apr 9, 2026

Description

Migrate all node-side console.warn/console.error/throw new Error patterns to structured diagnostics using @antfu/experimental-logs-sdk. Each error/warning now gets a unique code (DTK0001DTK0032 for core/rpc, RDDT0001RDDT0002 for rolldown) with auto-generated docs URLs and ANSI-formatted console output.

  • Add @antfu/experimental-logs-sdk (^0.0.3) as dependency to rpc, core, and rolldown packages
  • Create diagnostics.ts in each package with defineDiagnostics() + createLogger() — flat code keys like DTK0001 (no prefix option)
  • Migrate 34 error/warning sites across 19 source files to use the logger
  • Add 35 VitePress documentation pages under docs/errors/ (one per code + index) with cause, fix, examples, and source links
  • Add "Error Reference" sidebar section to VitePress config
  • Update test assertions in packages/rpc/src/dumps.test.ts to match new CodedError message format

resolves #155

Linked Issues

Additional context

  • Only node-side code is migrated; client-side Vue components/webcomponents are excluded
  • Code prefixes: DTK = DevTools Kit (rpc + core), RDDT = Rolldown DevTools, VDT reserved for the vite package
  • The rpc package uses plainFormatter (no ansis dependency); core and rolldown use ansiFormatter

Replace inconsistent console.warn/error/throw patterns with structured
diagnostics using @antfu/experimental-logs-sdk. Each error gets a unique
code (DTK0001-DTK0032 for core/rpc, RDDT0001-RDDT0002 for rolldown)
with auto-generated docs URLs and ANSI-formatted output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 9, 2026

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@285

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@285

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@285

@vitejs/devtools-rpc

npm i https://pkg.pr.new/@vitejs/devtools-rpc@285

@vitejs/devtools-self-inspect

npm i https://pkg.pr.new/@vitejs/devtools-self-inspect@285

commit: 5755db9

@antfu antfu marked this pull request as draft April 9, 2026 07:58
antfu and others added 5 commits April 9, 2026 17:00
TypeScript doesn't narrow types after `logger.CODE().throw()` because
the return type inference doesn't propagate `never` through the chained
call. Adding `throw` before the expression fixes control flow analysis.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Package renamed from `@antfu/experimental-logs-sdk` to `logs-sdk`
(now under vercel-labs/logs-sdk). Updated all imports, catalog entry,
and docs references.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the error code system (prefixes, numbering, diagnostics files)
and step-by-step instructions for adding new errors so future agents
follow the established pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename `reporter` to `reporters` in createLogger options to match the
updated API.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@antfu antfu marked this pull request as ready for review April 17, 2026 00:04
@antfu antfu merged commit 9bd928d into main Apr 17, 2026
9 checks passed
@antfu antfu deleted the antfu/migrate-logs-sdk branch April 17, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant